def Option():
    print("--------信息管理系统--------")
    print("---------功能选项---------")
    print("1.添加信息：")
    print("2.按姓氏查询：")
    print("3.按名字查询：")
    print("8.退出系统")


def init(data):
    data['family_name'] = {}
    data['name'] = {}
    data['age'] = {}
    data['sex'] = {}
    data['weixin'] = {}


def lookup(data,label,name):
    """

    :param data:
    :param label:
    :param name:
    :return:
    """
    return data[label].get(name)


def store(datas,full_name):
    names = [full_name[0:1],full_name[1:]]
    labels = 'family_name','name'
    for label,name in zip(labels,names):
        people = lookup(datas,label,name)
        if people:
            people.append(full_name)
        else:
            datas[label][name] = [full_name]
def age(datas,full_age):
    pass

Option()
message = {}
init(message)
list_data=['张雨绮','张治中','张耀扬','张云春','张静初'
            ,'张恭庆','张作霖','张铁林','张信哲','张曼玉'
            ,'郑成功','郑宝荣','郑晓勇','郑国忠','郑大天'
            ,'郑耀文','郑丽','郑志厚','郑宝果','郑智文'
            ,'孙伟','孙思邈','孙权','孙尚香','孙子',
           ]

#print(message)
while True:
    for a in range(1, len(list_data)):
        store(message, list_data[a])
    Choose = int(input("请输入相应的功能选项："))
    if Choose==1:
        print("------------------------")
        add = input("请输入您要添加的姓名：")
        list_data.append(add)
    if Choose==2:
        print("------------------------")
        fn = input("请输入您要查找的姓氏：")
        fns = lookup(message, 'family_name', fn)
        if fns != None:
            print("------------------------")
            print("您好！姓氏为“{}”的有：".format(fn),'\n',"{}".format(fns))
        else:
            print("------------------------")
            print("系统里找不到此姓氏；建议您使用名字查询")
    elif Choose==3:
        print("------------------------")
        n = input("请输入您要查找的名字：")
        ns = lookup(message,'name',n)
        if ns != None:
            print("------------------------")
            print("您好！名字为“{}”的有：".format(n),'\n',"{}".format(ns))
        else:
            print("------------------------")
            print("系统里找不到此名字；建议您使用姓氏查询")
    elif Choose==8:
        print("------------------------")
        print("成功退出系统！")
        break
    else:
        print("请输入正确的功能选项！")